//
//  Car.m
//  CarParts-Split
//
//  Created by quentin on 15/8/26.
//  Copyright (c) 2015年 QuentinLabs. All rights reserved.
//

#import "Car.h"
#import "Tire.h"
#import "Engine.h"


@implementation Car

-(id) init
{
    if (self == [super init]) {
//        engine = [Engine new];
//        for (int i = 0; i < 4; ++i) {
//            tires[i] = [Tire new];
//        }
    }
    return (self);
}


-(Engine*) engine
{
    return engine;
}

-(void) setEngine:(Engine *)newEngine
{
    engine = newEngine;
}

-(void) setTire:(Tire *)tire atIndex:(int)index
{
    if(index <0 || index > 3)
    {
        NSLog(@"bad index(%d)in setTireAtIndex:",index);
        exit(1);
    }
    tires[index] = tire;
}


-(Tire*) tireAtIndex:(int)index
{
    if (index <0 || index > 3) {
        NSLog(@"bad index(%d) in tireAtIndex:",index);
        exit(1);
    }
    return tires[index];
}

-(void) print
{
    NSLog(@"%@",engine);
    NSLog(@"%@",tires[0]);
    NSLog(@"%@",tires[1]);
    NSLog(@"%@",tires[2]);
    NSLog(@"%@",tires[3]);
}//print

@end
